package com.hotel.controller;

import com.hotel.service.ExtendedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/admin")
public class ExtendedController {
    @Autowired
    private ExtendedService extendedService;
    //获取仪表盘所需参数
    @GetMapping("/dashboard/overview")
    public Map<String, Object> getDashboardOverview() {
        return extendedService.getDashboardOverview();
    }
    //获取房间统计数据
    @GetMapping("/stats/rooms")
    public List<Map<String, Object>> getRoomStats(@RequestParam(required = false) Map<String, Object> params) {
        if((params.get("room_type") == null && params.get("startDate") == null && params.get("endDate") == null))
            return extendedService.getAllRoomStats();
        return extendedService.getRoomStats(params);
    }
    //获取消费统计数据
    @GetMapping("/stats/consumptions")
    public List<Map<String, Object>> getConsumptionStats(@RequestParam(required = false) Map<String, Object> params) {
        if((params.get("item_name") == null && params.get("startDate") == null && params.get("endDate") == null))
            return extendedService.getAllConsumptionStats();
        return extendedService.getConsumptionStats(params);
    }
}
